package com.kamistoat.meimeimall.meimeimallorder.localTCC;

import com.kamistoat.meimeimall.common.To.paymentTo.PayAsyncTo;
import com.kamistoat.meimeimall.meimeimallorder.vo.OrderCreateVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface OrderServiceLocalTCC {
    /**
     * 下单阶段，保存未支付的未经拆分的总订单数据。
     *
     * @param orderCreateVo
     */
    @TwoPhaseBusinessAction(name = "saveUnpayOrder", commitMethod = "saveUnpayOrderCommit", rollbackMethod = "saveUnpayOrderRollback")
    void saveUnpayOrder(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "orderCreateVo") OrderCreateVo orderCreateVo);

    boolean saveUnpayOrderCommit(BusinessActionContext businessActionContext);

    boolean saveUnpayOrderRollback(BusinessActionContext businessActionContext);

    /**
     * 收到支付成功回调后，如果是成功支付，则拆分总订单
     */
    @TwoPhaseBusinessAction(name = "savePayedSubOrder", commitMethod = "savePayedSubOrderCommit", rollbackMethod = "savePayedSubOrderRollback")
    void savePayedSubOrder(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "payAsyncTo") PayAsyncTo payAsyncTo);

    boolean savePayedSubOrderCommit(BusinessActionContext businessActionContext);

    boolean savePayedSubOrderRollback(BusinessActionContext businessActionContext);


}
